import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Class <code>ArffFileRetriever</code> 
 */
public class Evaluator {
	
	private ArrayList<Integer> narrFaultPosLine = new ArrayList<Integer>();

	/** Line Number to Suspiciousness */
	private  ArrayList< Pair<Integer,Double> > mStatementSuspicious = new ArrayList< Pair<Integer,Double> >();

	private int calcFaultRank() throws Exception{
		for(int i =0; i<mStatementSuspicious.size(); i++){
			for(int j=0; j < narrFaultPosLine.size(); j++){
				if(mStatementSuspicious.get(i).getFirst().equals(narrFaultPosLine.get(j))){
					return i;
				}
			}
		}
		throw new Exception("Fault Line Not Found");
	}

	public Pair calcFaultRankPercentTBest() throws Exception{
		int i = calcFaultRank();		
		while(i>0 && mStatementSuspicious.get(i-1).getSecond().equals(mStatementSuspicious.get(i).getSecond()) )
			i--;
		return new Pair(i,mStatementSuspicious.size());
	}

	public Pair<Integer,Integer> calcFaultRankPercentTWorst() throws Exception{
		int i = calcFaultRank();
		
		while(i<mStatementSuspicious.size()-1 && mStatementSuspicious.get(i+1).getSecond().equals(mStatementSuspicious.get(i).getSecond()) )
			i++;
		return new Pair(i,mStatementSuspicious.size());
	}
	
	
	

	public void readSuspiciousLine(InputStream istSuspiciousTopLine) throws IOException{

		Scanner scScanner = new Scanner(istSuspiciousTopLine);

		while (scScanner.hasNextInt()){
			
			mStatementSuspicious.add(new Pair<Integer,Double>(scScanner.nextInt(),scScanner.nextDouble()));
		
		}

		
	}

	public void readFaultPosLine(InputStream istFaultPosLine) throws IOException{

		Scanner scScanner = new Scanner(istFaultPosLine);

		while (scScanner.hasNextInt()){
			
			narrFaultPosLine.add(scScanner.nextInt());
		
		}


	}
	
	public static void main(String[] args) throws IOException {
		
		Evaluator eval = new Evaluator();

		/**Input SuspiciousTop File Stream*/
		FileInputStream fiSuspiciousTopFile = new FileInputStream(args[0]);
		eval.readSuspiciousLine(fiSuspiciousTopFile);

		/**Input FaultPos File Stream*/
		FileInputStream fiFaultPosFile = new FileInputStream(args[1]);
		eval.readFaultPosLine(fiFaultPosFile);
		
		try {
			
			Pair<Integer,Integer > TBest = eval.calcFaultRankPercentTBest();
			Pair<Integer,Integer > TWorst = eval.calcFaultRankPercentTWorst();			
			
			System.out.format("%d\t%d\t%d\t%d\n",
					TBest.getFirst(),
					TBest.getSecond(),
					TWorst.getFirst(),
					TWorst.getSecond());
			
		} catch (Exception e) {
			System.err.println(e);
		}
		
	}
	
	

}
	